#include<iostream>
using namespace std;
const int N = 1e4 + 10;
int g[N][N];
int f[N][N];
int n; 
int dfs(int x, int y)
{
	if (x == 1 && y == 1)return g[1][1];
	if (x <= n && x >= 1 && y <= n && y >= 1) {
		return max(dfs(x - 1, y), dfs(x, y - 1)) + g[x][y];
	}
	return 0;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> g[i][j];
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			/*f[i][j] = max(f[i][j - 1], f[i - 1][j]) + g[i][j];
			cout << "i==" << i << "   " << "j==" << j << "   f[i][j]==" << f[i][j] << endl;*/
			cout << dfs(i, j) << endl;
		}
		cout << endl;
	}
	return 0;
}